<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Chap2Controller extends Controller
{
    public function actionIndex()
    {
        $this->render("Index");
    }
    
    public function actionTextFieldCustomize()
    {
        $this->render("TextFieldCustomize");
    }
    
    public function actionTextArea()
    {
        echo CHtml::form();
        $htmlOptions = array("cols" => 50,"rows" => 8);
        echo CHtml::textArea("mytext",NULL,$htmlOptions);
        echo CHtml::endForm();
    }
    
    public function actionCheckbox()
    {
        echo CHtml::form();
        
        echo CHtml::checkBox("book",FALSE,array("value" => "java"));
        echo Chtml::label("JAVA",NULL);
        
        echo "<br/>";
        
        echo CHtml::checkBox("book",FALSE,array("value" => "php"));
        echo Chtml::label("PHP",NULL);
        
        echo CHtml::endForm();
    }
    
    public function actionCheckboxList()
    {
        $data = array(
            "1001" => "JAVA",
            "1002" => "PHP",
            "1003" => "Yii Framework",
            "1004" => "Kohan");
        
        echo CHtml::checkBoxList("chk",NULL,$data);
    }
    
    public function actionRadio()
    {
        echo CHtml::form();
        
        echo CHtml::radioButton("sex",FALSE,array("value" => "f"));
        echo Chtml::label("Female",NULL);
        
        echo CHtml::radioButton("sex",FALSE,array("value" => "m"));
        echo Chtml::label("Male",NULL);
        
        echo CHtml::endForm();
    }
    
    public function actionRadioList()
    {
        $data = array(
            "1001" => "JAVA",
            "1002" => "PHP",
            "1003" => "Yii Framework");
        echo CHtml::radioButtonList("book",NULL,$data);
    }
    
    public function actionPassword()
    {
        echo CHtml::passwordField("mypassword");
    }
    
    public function actionFile()
    {
        echo "File: ";
        echo CHtml::fileField("myfile");
    }
    
    public function actionHidden()
    {
        echo CHtml::hiddenField("myhidden",10);
    }
    
    public function actionDropdownList()
    {
        $data = array(
            "1001" => "JAVA",
            "1002" => "PHP",
            "1003" => "Yii Framework");
        echo CHtml::dropDownList("ddl",NULL,$data);
    }
    
    public function actionForm()
    {
        if(!empty($_POST))
        {
            echo "myinput = ".$_POST["myinput"];
        }
        $this->render("Form");
    }
    
    public function actionCal()
    {
        $x = 0;
        $y = 0;
        $result = 0;
        
        if(!empty($_POST))
        {
            $x = $_POST["x"];
            $y = $_POST["y"];
            $result = $x + $y;
        }
        $this->render("Cal",array(
            "x" => $x,
            "y" => $y,
            "result" => $result
        ));
    }
}
?>
